using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PhoneNetwork
{
    public partial class frmStatistics : Form
    {
        public frmStatistics()
        {
            InitializeComponent();
        }

        private void frmStatistics_Load(object sender, EventArgs e)
        {

        }
        internal void Add(EventType evType, string NodeFrom, string NodeTo, string Path)
        {
            ListViewItem lstItem = new ListViewItem(new string[] { listView1.Items.Count.ToString(), evType.ToString(), NodeFrom, NodeTo, Path });
            lstItem.BackColor = Color.LightGray;
            if (evType == EventType.EndCall)
                lstItem.BackColor = Color.DarkGray;
            listView1.Items.Add(lstItem);
        }
        internal string GetPath(string NodeFrom, string NodeTo)
        {
            foreach (ListViewItem item in listView1.Items)
                if (item.SubItems[2].Text == NodeFrom && item.SubItems[3].Text == NodeTo)
                    return item.SubItems[4].Text;
            return "";
        }
        internal void Edit(string NodeFrom, string NodeTo, string newPath)
        {
            for (int i = listView1.Items.Count - 1; i >= 0; i--)
            {
                ListViewItem item = listView1.Items[i];
                if (item.SubItems[1].Text == "StartCall" && item.SubItems[2].Text == NodeFrom && item.SubItems[3].Text == NodeTo)
                {
                    item.SubItems[4].Text = newPath;
                    break;
                }
            }
        }

        internal void Clear()
        {
            listView1.Items.Clear();
        }
    }
    public enum EventType
    {
        StartCall,
        EndCall
    }
}